package cn.lcfms.cms.model;

import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.lcfms.app.admin.bean.ArticleBean;
import cn.lcfms.bin.service.BaseService;
import cn.lcfms.cms.CmsDataBase;

public class Getzj extends CmsDataBase{

	public Getzj(HttpServletRequest request, HttpServletResponse response, int id, BaseService service) {
		super(request, response, id, service);
	}

	@Override
	public void data() {
		ArticleBean bean=service.selectOne(ArticleBean.class, id);
		request.setAttribute("article", bean);
		service.leftJoin("files").on("files.file_type_id=articles.id and file_type='articles'");
		service.where("articles.category_id=17");
		service.column("articles.title","articles.id","articles.desc","files.thumbnail","files.original");
		service.groupBy("articles.id");
		List<HashMap<String, Object>> list = service.selectList();	
		for (int i = 0; i < list.size(); i++) {
			HashMap<String, Object> map=list.get(i);
			int id=(int) map.get("id");
			if(id==bean.getId()) {
				String original=(String) map.get("original");
				request.setAttribute("original", original);
				list.remove(map);
				break;
			}
		}
		request.setAttribute("zjlist", list);
		HashMap<String, Object> map = service.setTable("categories").column("id","pid","title").where("id="+bean.getCategory_id()).selectMap();
		request.setAttribute("menu_title_1", map);	
	}

}
